package com.qing.demo.netty.server;

import com.qing.demo.netty.codec.MyDecoder;
import com.qing.demo.netty.codec.MyEncoder;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.Delimiters;
import io.netty.handler.codec.FixedLengthFrameDecoder;
import io.netty.handler.codec.LineBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;

import java.nio.charset.Charset;


/**
 * @author caozhipeng
 * @date 2025/7/25
 */
public class MyChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
//        解码转String，指定编码格式
        socketChannel.pipeline().addLast(new MyDecoder());
//        编码转String，指定编码格式
        socketChannel.pipeline().addLast(new MyEncoder());
//        在管道中添加自定义的业务处理类
        socketChannel.pipeline().addLast(new MyServerHandler());
    }
}
